﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;
using System.Web.UI.WebControls;


/// <summary>
///GetWebHtml 的摘要说明
/// </summary>
namespace HtmlTools
{
    public class GetWebHtml
    {

        public static string GetHtml(string url,string econd)
        {
             string returnhtml= string.Empty;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "Get";
            if (request.Timeout > 100000)
            {// 连接超时，默认值是100，000(1分钟)
                return returnhtml;
            }
            else
            {
                request.ContentType = "application/x-www-form-urlencoded ";
                try
                {
                    WebResponse response = request.GetResponse();
                    Stream s = response.GetResponseStream();
                    StreamReader sr = new StreamReader(s, System.Text.Encoding.GetEncoding(econd));
                    returnhtml = sr.ReadToEnd();
                    s.Close();
                    sr.Close();
                    return returnhtml;
                }
                catch
                {
                   return  returnhtml;
                }

            }

        }



        
    }
}